package com.ikun.yummy.utils;

import android.content.Context;
import android.os.Environment;

import com.ikun.yummy.App;

public class CommonUtils {
    //判断是否是邮箱
    public static boolean isEmail(String mail){
      return mail.matches("[a-zA-Z0-9_]{1,}[@][a-z0-9]{2,3}[.][a-z]{2,3}");
    }
    public static String createRandom(int length){
        StringBuilder retStr;
        String strTable = "1234567890abcdefghijkmnpqrstuvwxyz";
        int len = strTable.length();
        boolean bDone = true;
        do {
            retStr = new StringBuilder();
            int count = 0;
            for (int i = 0; i < length; i++) {
                double dblR = Math.random() * len;
                int intR = (int) Math.floor(dblR);
                char c = strTable.charAt(intR);
                if (('0' <= c) && (c <= '9')) {
                    count++;
                }
                retStr.append(strTable.charAt(intR));
            }
            if (count >= 2) {
                bDone = false;
            }
        } while (bDone);
        return retStr.toString();
    }
    public static String getPath(Context context){
        return context.getFilesDir().getAbsolutePath()+"/";
    }
}